<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition>
        <p:dialog id="VentaEditDlg" widgetVar="VentaEditDialog" modal="true" resizable="false"  appendTo="@(body)" header="#{myBundle.EditVentaTitle}" closeOnEscape="true">

            <h:form id="VentaEditForm">

                <h:panelGroup id="display">
                    <p:panelGrid  columns="2" columnClasses="column" rendered="#{ventaController.selected != null}">


                        <h:outputLabel value="#{myBundle.EditVentaLabel_codigo}" for="codigo" />
                        <h:outputText id="codigo" value="#{ventaController.selected.codigo}" />

                        <p:outputLabel value="#{myBundle.EditVentaLabel_fecha}" for="fecha" />
                        <p:calendar id="fecha" pattern="MM/dd/yyyy HH:mm:ss" value="#{ventaController.selected.fecha}" title="#{myBundle.EditVentaTitle_fecha}"  showOn="button"/>

                        <p:outputLabel value="#{myBundle.EditVentaLabel_monto}" for="monto" />
                        <p:inputText id="monto" value="#{ventaController.selected.monto}" title="#{myBundle.EditVentaTitle_monto}"/>

                        <p:outputLabel value="#{myBundle.EditVentaLabel_codpersona}" for="codpersona" />
                        <p:selectOneMenu id="codpersona" value="#{ventaController.selected.codpersona}"  converter="personaConverter">
                            <f:selectItem itemLabel="#{myBundle.SelectOneMessage}"/>
                            <f:selectItems value="#{personaController.items}"
                                           var="codpersonaItem"
                                           itemValue="#{codpersonaItem}"
                                           itemLabel="#{codpersonaItem.codigo.toString()}"
                                           />

                        </p:selectOneMenu>
                    </p:panelGrid>
                    <p:commandButton actionListener="#{ventaController.save}" value="#{myBundle.Save}" update="display,:VentaListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,VentaEditDialog);">
                        <p:confirm header="#{myBundle.ConfirmationHeader}" message="#{myBundle.ConfirmEditMessage}" icon="ui-icon-alert"/>
                    </p:commandButton>
                    <p:commandButton value="#{myBundle.Cancel}" onclick="VentaEditDialog.hide()"/>
                </h:panelGroup>

            </h:form>

        </p:dialog>

    </ui:composition>

</html>
